import {debounce} from './utils'
import BackTop from 'components/content/backTop/BackTop'
import {BACKTOP} from "common/const"


export const itemListenerMixin = {
  data(){
    return{
      itemImgListener:null  
    }
  },
  mounted(){
    const refresh = debounce(this.$refs.scroll.refresh)

    this.itemImgListener = () =>{
      refresh()
    }
    this.$bus.$on('itemImageLoad',this.itemImgListener)
    
  }
}
export const backTopMixin = {
  components:{
    BackTop
  },
  data(){
    return{
      isShowBackTop:false
    }
    
  },
  methods:{
    backClick(){
      this.$refs.scroll.scrollTo(0,0,2000)
    },
    ListenShowBackTop(position){
      this.isShowBackTop = -position.y>BACKTOP
    }
  }
}